<template>
	<view class="">
		<view class="mine_info">
			<view class="nologin hlogin">
				<view class="pict" @click="topersonal">
					<image :src="userInfo.Avatar" mode=""></image>
				</view>
				<view class="username">
					<span>{{userInfo.MemberName}}</span>
					 <!-- <image src="https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/discover/mem_svip.png" mode=""></image> -->
					 <image v-if="club_info.Id" src="https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/manner.png" mode=""></image>
				</view>
			</view>
		</view>
		<!-- 加入的跑团 -->
		<view class="mine_run">
			<view class="mine_run_title">
				我的跑团
			</view>
			<view class="mine_run_bottom">
				<!-- <image src="https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/othertwo/mine_01.png" mode=""></image> -->
				<image src="https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/99.png" mode=""></image>
				<view class="joinrun" v-if="club_info.Id">
					<view class="mine_run_l">
						<view class="login">
							<view class="login_pic">
								<image :src="club_info.Logo" mode=""></image>
							</view>
							<view class="login_r">
								<view class="login_r_t">
									<span>{{club_info.Title}}</span><image v-if="club_info.cation_type" src="https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/other/group_logo.png" mode=""></image>
								</view>
								<view class="login_r_b">
									<i class="icon">&#xe672;</i>{{club_info.City}}
								</view>
							</view>
						</view>
					</view>
					<view class="mine_run_r_j" @tap="tomyrun(userInfo.club_info.Id)">
						进入跑团
						<i class="icon icon_join">&#xe627;</i>
					</view>
				</view>
				<!-- 没加入跑团 -->
				<view v-else class="nojoinrun">
					<view class="mine_run_l ">
						您还没有加入跑团，快去加入跑团吧
					</view>
					<view class="mine_run_r mine_run_r_j" @tap="torungroup">
						加入跑团
						<i class="icon icon_join">&#xe627;</i>
					</view>
				</view>
			</view>
		</view>
		<view class="mine_enter_all" @tap="toregister(0)" >
			<view class="mine_enter_all_title">
				我的报名
			</view>
			<view class="mine_enter_all_look" >
				查看全部
				<i class="icon">&#xe637;</i>
			</view>
		</view>
		<view class="mine_noenter_some">
			<view class="mine_enter_some_j"  @tap="toregister(index+1)" v-for="(item,index) in noenternav" :key="index">
				<view class="pic pic_some">
					<image :src="item.src" mode=""></image>
					<!-- 指示点 -->
					<view v-if="item.state == '待支付'&&jude_pay 
					|| item.state == '待参与'&& jude_join.length
					|| item.state == '待审核'&&jude_verify
					" class="pic_bsdds"></view>
				</view>
				<span>{{item.state}}</span>
			</view>
		</view>
		<!-- 我的 -->
		<view class="myinformation">
			<view class="myinformation_item" @tap="topage(index)" v-for="(item,index) in mylist" :key="index">
				<view class="myinformation_item_l">
					<image :src="item.src" mode=""></image>
					{{item.title}}
				</view>
				<i class="icon myinformation_item_ricon" v-html="item.ricon"></i>
			</view>
		</view>
		<!-- loading 遮罩层 -->
		<loading v-if="loadflag"></loading>
	</view>
</template>

<script>
	import loading from "@/components/loading/loading.vue"
	export default {
		components: {loading},
		data() {
			return {
				loadflag:true,
				noenternav:[
					{icon:'&#xe647;',state:'待支付',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/three11.png'},
					{icon:'&#xe647;',state:'待审核',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/three12.png'},
					{icon:'&#xe647;',state:'待参与',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/three13.png'},
					{icon:'&#xe647;',state:'已完成',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/three14.png'},
				],
				enternav:[
					{icon:'&#xe647;',state:'待审核',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/mine/mine_sh02.png'},
					{icon:'&#xe647;',state:'待参与',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/mine/mine_dcy02.png'},
					{icon:'&#xe647;',state:'退款',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/mine/mine_tk02.png'},
					{icon:'&#xe647;',state:'已完成',src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/mine/mine_end02.png'},
				],
				mylist:[
					{src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/three02.png',title:'我的成绩',ricon:'&#xe637;'},
					{src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/three03.png',title:'账号设置',ricon:'&#xe637;'},
					{src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/newPicter/three01.png',title:'联系客服',ricon:'&#xe637;'}
				],
				userInfo:{},
				club_info:{},
				list:[],
				jude_join: [] ,// 判断带参与的
				jude_pay:false,
				jude_verify: false
			}
		},
		mounted() {
			this.getUserInfo()
			this.getOrderList()
		},
		watch: {
			$route(to,from) {
				if(from.path == '/pageC/mine/personal') {
					this.getUserInfo()
				}
			}
		},
		methods: {
			getOrderList() {
			this.ajax('order/orderList', {
				success: res => {
					var nowTime=new Date().getTime();
					this.list = res.msg.data;
					var or_list = res.msg.data;
					or_list.forEach(item => {
						var info = item.active_info;
						// 报名开始时时间戳
						info.sing_start_c = new Date(info.sign_up_start).getTime();
						// 报名结束时间
						info.sing_end_c = new Date(info.sign_up_end).getTime();
						// 活动开始时间
						info.start_time_a = info.start_time.split(' ')[0];
						info.start_time_c = new Date(info.start_time).getTime();
						 // console.log (nowTime > info.sing_end_c && nowTime < info.start_time_c && info.type !=3 &&item.state == 2);
						if( item.verify == 1 && nowTime < info.start_time_c && info.type !=3 &&item.state == 2) {
							info.join_state = 5
							this.jude_join = this.jude_join.concat(info.join_state)
						}
						// 活动结束时间
						info.end_time_c = new Date(info.end_time).getTime();
						if(item.state == 1) {
							this.jude_pay = true
						}
						if(item.state == 2 && item.verify == 0) {
							this.jude_verify = true
						}
					});
				}
			});
		},
			// 获取用户信息
			getUserInfo () {
				this.ajax('user/userInfo', {
					success: res => {
						 // console.log (res);
						var reg = RegExp('/?x-oss-process=image/');
						if(res.msg.Avatar) {
							res.msg.Avatar = res.msg.Avatar.replace("http:","https:")
							if(!reg.test(res.msg.Avatar)) {
								uni.getImageInfo({
									src: res.msg.Avatar,
									success: image => {
										if (image.width > image.height) {
											res.msg.Avatar = res.msg.Avatar + '?x-oss-process=image/rotate,0';
										}
									}
								});
							}
						}
						if (res.msg.club_info.Logo) {
							res.msg.club_info.Logo = res.msg.club_info.Logo.replace("http:","https:")
						}
						this.userInfo = res.msg
						//  // console.log (this.userInfo.Avatar);
						this.club_info = res.msg.club_info
						var that = this;
						if(!reg.test(this.club_info.Logo)) {
							uni.getImageInfo({
								src: this.club_info.Logo,
								success: image => {
								  if(image.width > image.height) {
									  that.club_info.Logo = that.club_info.Logo+'?x-oss-process=image/rotate,0';
								  }
								}
							});
						}
						  
						that.loadflag = false
						uni.hideLoading()
					}
				})
			},
			// 去往报名页
			toregister(key) {
				uni.navigateTo({
					url:'/pageC/mine/register?state='+key
				})
			},
			topage(key) {
				switch (key){
					case 0:
						uni.navigateTo({
							url:'/pageC/mine/mygrade'
						})
						break;
					case 1:
						uni.navigateTo({
							url:'/pageC/mine/setting'
						})
						break;
					default:
						break;
				}
			},
			topersonal () {
				uni.navigateTo({
					url:'/pageC/mine/personal'
				})
			},
			// 进入跑团
			tomyrun (key) {
				uni.navigateTo({
					url:'/pageB/run/rungroup?id='+key
				})
			},
			torungroup () {
				uni.navigateTo({
					url:'/pageC/rungroup/rungroup'
				})
			}
		}
	}
</script>

<style lang="less" scoped> 
	@import url('../../static/less/mine/mine.less');
</style>
<style > 
page {
	background-color: #F2F2F2;
}
</style>
